#include "newactdlg.h"
#include "ui_newactdlg.h"


#include <QDebug>
#include <QMessageBox>


Newactdlg::Newactdlg(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Newactdlg)
{
    ui->setupUi(this);
    QVector<QList<QAbstractButton *>> Vec_btn;
    Vec_btn.append(ui->v1->buttons());
    Vec_btn.append(ui->v2->buttons());
    Vec_btn.append(ui->v3->buttons());
    Vec_btn.append(ui->v4->buttons());
    Vec_btn.append(ui->v5->buttons());
    Vec_btn.append(ui->v6->buttons());
    for(int i = 0;i<Vec_btn.size();i++){
        for(int j = 0;j<Vec_btn.at(i).size();j++){
            connect((QCheckBox*)Vec_btn.at(i).at(j),&QCheckBox::stateChanged, [=](){
                int ys = i>j?j:j+1;qDebug("i = %d,j = %d,ys = %d",i,j,ys);
                emit this->CheckAt(i,ys);
            });
        }
    }

    connect(ui->btn_Finish,&QPushButton::clicked,this,&on_btnFinish_pushed);
    connect(ui->btn_Help,&QPushButton::clicked,this,&on_btnHelp_pushed);

}

Newactdlg::~Newactdlg()
{
    delete ui;
}

void Newactdlg::closeEvent(QCloseEvent *event)
{
    qDebug()<<"closed";
    delete this;
}

void Newactdlg::on_btnFinish_pushed()
{
    this->close();
}


void Newactdlg::on_btnHelp_pushed()
{
    QMessageBox::about(this,"帮助","勾选以确定每个顶点的终点。尽量\n使顶点的出度和入度不为0");
}
